using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
namespace CoreData
{
    public class message
    {
            public long id{get;set;}
            public long sellerid{get;set;}
            public long buyerid{get;set;}
            public string messages{get;set;}
            public DateTime senddate{get;set;}
            public bool view{get;set;}
            public bool active{get;set;}
            public long workid{get;set;}
            public bool isnew{get;set;}
         
        public message()
        {       
                    messages ="";   
        }
        
       static message DynamicCast<T>(object row_data, object row_header) where T : message
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           message ret = new message();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                      case  "id":
                        ret.id = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "sellerid":
                        ret.sellerid = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "buyerid":
                        ret.buyerid = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "messages":
                        ret.messages = ConvertObject.ToString(dt[column]);
                       break;
                      case  "senddate":
                        ret.senddate = ConvertObject.ToDateTime(dt[column]);
                       break;
                      case  "view":
                        ret.view = ConvertObject.ToBool(dt[column]);
                       break;
                      case  "active":
                        ret.active = ConvertObject.ToBool(dt[column]);
                       break;
                      case  "workid":
                        ret.workid = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "isnew":
                        ret.isnew = ConvertObject.ToBool(dt[column]);
                       break;
                
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}
